home *** CD-ROM | disk | FTP | other *** search
- #!/bin/bash
-
- # Fixup /etc/sysconfig/daemons/
-
- copyopts='ONBOOT OPTIONS FS_LIST OPTIONS_SMB OPTIONS_NMB NFSD_OPTIONS MOUNTD_OPTIONS OPTIONS_S OPTIONS_D OPTIONS_SYSLOGD OPTIONS_KLOGD INTERNAL_INTERFACE INTERNAL_NETWORK LEVEL CONFIGURED DAEMON_ARGS'
-
- for i in /etc/sysconfig/daemons/*.rpmnew
- do
- echo "converting .rpmnew to .rpmsave $i"
- if [ "$i" != "/etc/sysconfig/daemons/*.rpmnew" ] ; then
- daemonf=`echo $i | sed -e 's/.rpmnew//'`
- echo mv $daemonf $daemonf.rpmsave
- mv $daemonf $daemonf.rpmsave
- echo mv $i $daemonf
- mv $i $daemonf
- fi
- done
-
- for i in /etc/sysconfig/daemons/*.rpmsave
- do
- echo "processing $i"
- if [ "$i" != "/etc/sysconfig/daemons/*.rpmsave" ] ; then
- daemonf=`echo $i | sed -e 's/.rpmsave//'`
- for opt in $copyopts ; do
- opts=`get_val -f $i $opt`
- oldopts=`get_val -f $daemonf $opt`
- # Only migrate values which are not empty.
- # (might be discussable)
- if [ -n "$opts" ]; then
- echo "$daemonf setting $opt to $opts"
- set_val -f $daemonf -- $opt "$opts"
- fi
- done
-
- fi
- done
-
- # Fixup mounts
- if ! grep usbdevfs /etc/fstab > /dev/null ; then
- echo "none /proc/bus/usb usbdevfs defaults 0 0" >> /etc/fstab
- fi
- if ! grep devpts /etc/fstab > /dev/null ; then
- echo "none /dev/pts devpts gid=5,mode=620 0 0" >> /etc/fstab
- mkdir /dev/pts
- fi
-
- if ! grep /dev/cdrom /etc/fstab > /dev/null ; then
- echo "/dev/cdrom /mnt/cdrom iso9660 ro,user,noauto,exec 0 0" >> /etc/fstab
- mkdir /mnt/cdrom
- fi
-
- # Fix users and groups.
- # Ugly inline PERL, since we just copy this script into the updated system
-
- perl -e << EoF '
- # return if something is not as used.
- exit 0 if (! -f "/etc/passwd");
- exit 0 if (! -f "/etc/passwd~");
- exit 0 if (! -f "/etc/group");
- exit 0 if (! -f "/etc/group~");
-
- open(DIFF,"diff -u /etc/group /etc/group~|");
- $junk=<DIFF>; $junk=<DIFF>; $junk=<DIFF>;
- %needadd=();
- while (<DIFF>) {
- chomp;
- if (/^\+/) {
- s/^\+//;
- @foo=split(/:/);
- next if ($#foo<2);
- $needadd{$foo[0]}=$_;
- next;
- }
- if (/^\-/) {
- s/^\-//;
- @foo=split(/:/);
- next if ($#foo<2);
- $needadd{$foo[0]} = 0;
- next;
- }
- }
-
- foreach (keys %needadd) {
- next if (!$needadd{$_});
- @foo = split(/:/,$needadd{$_});
- print STDERR "/usr/sbin/groupadd -g $foo[2] $foo[0]\n";
- system("/usr/sbin/groupadd -g $foo[2] $foo[0]") && warn "system groupadd failed.\n";
- }
- close(DIFF);
-
- open(DIFF,"diff -u /etc/passwd /etc/passwd~|");
- $junk=<DIFF>; $junk=<DIFF>; $junk=<DIFF>;
- %needadd=();
- while (<DIFF>) {
- chomp;
- if (/^\+/) {
- s/^\+//;
- @foo=split(/:/);
- next if ($#foo<6);
- $needadd{$foo[0]}=$_;
- next;
- }
- if (/^\-/) {
- s/^\-//;
- @foo=split(/:/);
- next if ($#foo<6);
- $needadd{$foo[0]} = 0;
- next;
- }
- }
- close(DIFF);
-
- foreach (keys %needadd) {
- next if (!$needadd{$_});
- @foo = split(/:/,$needadd{$_});
- print STDERR "/usr/sbin/useradd -p $foo[1] -u $foo[2] -g $foo[3] -c $foo[4] -d $foo[5] -s $foo[6] $foo[0]\n";
- system("/usr/sbin/useradd -p $foo[1] -u $foo[2] -g $foo[3] -c \"$foo[4]\" -d $foo[5] -s $foo[6] $foo[0]") && warn "system useradd failed.\n";
- }
-
- # FIXME FIXME FIXME: does not handle /etc/shadow. But those system accounts
- # usually do not add passwords there anyway.
- EoF
- '
-
- # fixup probably missing init.d symlinks (due to broken PHI magic)
- for i in network netmount slpd firewall portmap
- do
- /usr/lib/LSB/init-install $i
- done
-